Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): add samples for MR CMEK #14674

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

panerorenn9541
Copy link

@panerorenn9541 panerorenn9541 commented Aug 29, 2024

Add samples for MR CMEK database creation, backup creation, copy backup, and backup restore.


This change is Reviewable

@panerorenn9541 panerorenn9541 requested a review from a team as a code owner August 29, 2024 18:25
Copy link

snippet-bot bot commented Aug 29, 2024

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Aug 29, 2024
Copy link

conventional-commit-lint-gcf bot commented Aug 29, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @panerorenn9541)


google/cloud/spanner/samples/samples.cc line 1304 at r1 (raw file):

                std::string const& src_project_id,
                std::string const& src_instance_id,
                std::string const& src_backup_id,

This is a lot of parameters for a function. Perhaps define a struct

struct BackupIdentifier {
  std::string project_id;
  std::string instance_id;
  std::string backup_id;
};

void CopyBackupWithMRCMEK(google::cloud::spanner_admin::DatabaseAdminClient client,
    BackupIdentifier const& src,
    BackupIdentifier const& dst,
...

google/cloud/spanner/samples/samples.cc line 1320 at r1 (raw file):

          .get();
  if (!copy_backup) throw std::move(copy_backup).status();
  std::cout << "Copy Backup " << copy_backup->name()  //

Are these comment sequences needed?


google/cloud/spanner/samples/samples.cc line 1355 at r1 (raw file):

  auto expire_time = TimestampAdd(
      google::cloud::spanner::MakeTimestamp(backup->expire_time()).value(),
      absl::Hours(7));

Can we use std::chrono instead of absl here?


google/cloud/spanner/samples/samples.cc line 1614 at r1 (raw file):

void CreateBackupWithMRCMEK(
    google::cloud::spanner_admin::DatabaseAdminClient client,
    std::string const& project_id, std::string const& instance_id,

Same comment about excessive number of parameters.


google/cloud/spanner/samples/samples.cc line 1650 at r1 (raw file):

      std::cout << ", ";
    }
  }

We seem to do this several times. Perhaps factor this out into a function.

Code quote:

      << " using encryption keys ";
  for (int i = 0; i < encryption_keys.size(); ++i) {
    std::cout << encryption_keys[i].FullName();
    if (i != encryption_keys.size() - 1) {
      std::cout << ", ";
    }
  }

Use struct and create function to print kms keys
Use std::chrono instead of absl::hours
Copy link
Author

@panerorenn9541 panerorenn9541 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @scotthart)


google/cloud/spanner/samples/samples.cc line 1304 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

This is a lot of parameters for a function. Perhaps define a struct

struct BackupIdentifier {
  std::string project_id;
  std::string instance_id;
  std::string backup_id;
};

void CopyBackupWithMRCMEK(google::cloud::spanner_admin::DatabaseAdminClient client,
    BackupIdentifier const& src,
    BackupIdentifier const& dst,
...

Done.


google/cloud/spanner/samples/samples.cc line 1320 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Are these comment sequences needed?

The logs are there for other copy/create/restores.


google/cloud/spanner/samples/samples.cc line 1355 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Can we use std::chrono instead of absl here?

Done.


google/cloud/spanner/samples/samples.cc line 1614 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Same comment about excessive number of parameters.

Done.


google/cloud/spanner/samples/samples.cc line 1650 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

We seem to do this several times. Perhaps factor this out into a function.

Done.

@dbolduc
Copy link
Member

dbolduc commented Oct 16, 2024

/gcbrun

@scotthart
Copy link
Member

/gcbrun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants